package com.woniuxy.lrz.carlproject.dao;

import com.woniuxy.lrz.carlproject.model.UserCar;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.woniuxy.lrz.carlproject.service.dto.userdto.CarDetailDTO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 用户车辆信息表 Mapper 接口
 * </p>
 *
 * @author lrz
 * @since 2022-09-28
 */
public interface UserCarMapper extends BaseMapper<UserCar> {

    @Select("select uc.*,cd.displacement,cd.car_year,cd.var_version,ct.car_type_name,cb.car_brand_name " +
            "from user_car uc join car_detail cd on uc.car_detail_id = cd.car_detail_id " +
            "join car_type ct on ct.car_type_id = cd.car_type_id" +
            " left join car_brand  cb on cb.car_brand_id = ct.car_brand_id where uc.user_id = #{uid}")
    List<CarDetailDTO> getCarDetails(@Param("uid") Integer userId);
}
